package cn.doitedu.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexDemo {


    public static void main(String[] args) {

        String events = "ACBDFABCB";
        //正则表达式
        //String regex = "(.*?A.*?B)";
        //String regex = "(B)";
        String regex = "(AB)";

        //编译指定的正则
        Pattern pattern = Pattern.compile(regex);
        //匹配指定的数据
        Matcher matcher = pattern.matcher(events);

        int count = 0;
        //从指定的数据中进行匹配
        while (matcher.find()) {
            count++;
        }

        System.out.println(count);

    }
}
